package com.boot.unity.api.modules.rzgjj.service;

import com.alibaba.fastjson.JSONObject;
import com.boot.unity.api.common.enums.DataSourceType;
import com.boot.unity.api.config.DataSource;
import com.boot.unity.api.config.DynamicDataSourceContextHolder;
import com.boot.unity.api.modules.rzgjj.dao.GjjSeachLogDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

@Service
public class GjjSeachLogService {

    @Autowired
    private GjjSeachLogDao gjjSeachLogDao;

    @DataSource(value = DataSourceType.SLAVE)
    public void insertAll(String name, String ipAddr, String body, String resultJson, String nowDate) {
        //手动切换数据源
        DynamicDataSourceContextHolder.setDataSourceType(DataSourceType.SLAVE.name());
        gjjSeachLogDao.insertAll(name,ipAddr, body, resultJson, nowDate);
        DynamicDataSourceContextHolder.clearDataSourceType();

    }
}
